package com.sky.mapper;

import com.sky.entity.Setmeal;
import com.sky.entity.SetmealDish;
import com.sky.vo.DishItemVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealDishMapper {

    // 根据菜品id查询套餐id
    List<Long> getSetmealIdsByDishIds(List<Long> dishIds);


    // 批量插入菜品
    void insertDish(List<SetmealDish> lists);


    //根据套餐ID删除套餐和菜品的关联关系
    @Delete("delete from setmeal_dish where setmeal_id = #{setmealId}")
    void delete(Long setmealId);

    // 根据套餐ID查询套餐所关联的菜品信息
    @Select("select  * from setmeal_dish where setmeal_id = #{setmealId}")
    List<SetmealDish> getDish(Long setmealId);

    // 根据套餐ID查询所包含的菜品并且连接菜品的描述和图片展示
    @Select("select  sd.name,sd.copies,d.image,d.description from setmeal_dish sd left outer join dish d on sd.dish_id = d.id where sd.setmeal_id = #{setmealId}")
    List<DishItemVO> selectDishBySetmealId(SetmealDish setmealDish);
}
